package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.ysd.entity.ChanPinXiangQing;
import com.ysd.util.DBManager;

public class ChanPingShouSuoDaoimpl {
	/**
	 * 通过chanPinName模糊查询产品详情的数据
	 * @param name
	 * @return
	 */
	public ArrayList<ChanPinXiangQing> getChanPingShouSuo(String name){
		Connection conn=DBManager.getConnection();
		ArrayList<ChanPinXiangQing> list=new ArrayList<ChanPinXiangQing>();
		Statement st=null;
		ResultSet rs=null;
		try {
			 st=conn.createStatement();
			String sql="SELECT * FROM chanpinxiangqing where chanPinName like  '%"+name+"%'";
			 rs=st.executeQuery(sql);
			while(rs.next()) {
				ChanPinXiangQing cpxq=new ChanPinXiangQing(rs.getInt("chanPingId"), rs.getString("chanPinName"), rs.getString("chanPinDiZhi"), rs.getInt("chanPinShouJia"), rs.getInt("chanPinShiChangJia"), rs.getString("chanPinPaiZi"), rs.getString("shiFouGuoqi"), rs.getString("shiFouXianLiang"), rs.getString("baoZhiQi"), rs.getString("jiaGongFang"), rs.getString("kouWei"), rs.getString("shenChangShang"), rs.getString("zhongLiang"), rs.getInt("fenleiId"),rs.getString("imgs")); 
				list.add(cpxq);
			}
			return list;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
